<template>
  <div class="base-table">
    <el-table 
      :data="tableData" 
      style="width: 100%" 
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection"></el-table-column>
      <el-table-column label="#" prop="id" width="180"></el-table-column>
      <el-table-column label="姓名" width="120" prop="username"></el-table-column>
      <el-table-column label="性别" width="80" prop="gender"></el-table-column>
      <el-table-column label="年龄" width="80" prop="age"></el-table-column>
      <el-table-column label="生日" width="180" prop="birthday"></el-table-column>
      <el-table-column label="地址" width="180" prop="address"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      multipleSelection: []
    };
  },
  methods: {
    handleEdit(index, row) {
      this.$emit("handleEdit", { index, row });
    },
    handleDelete(index, row) {
      this.$emit("handleDelete", { index, row });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.$emit("handleSelectionChange", this.multipleSelection);
    }
  }
};
</script>

<style>
</style>